<template>
	<view class="topone">
		<view class="">
			<image style="width: 100%;height:300rpx;position: relative;" :src="bgImage" mode=""></image>
			<!-- 头像 -->
			<view class="Khead">
				<view class="Kheadportrait">
					<view class="headportrait_A">
						<image :src="userinfo.avatarUrl" class="headportrait" mode="widthFix"></image>
					</view>
					<!-- @click="goLogin()" -->
					<view class="nickname">
						<text v-if="userinfo.nickName">{{ userinfo.nickName }}</text>
						<view v-else @click="getUserProfile()">点击登陆</view>
						<view>{{ userinfo.mobile }}</view>
					</view>
				</view>
			</view>
			<!-- 昵称 -->
			<view class="order">
				<view class="myorder">我的订单</view>
				<view class="order-type">
					<view @click="goOrder">
						<image src="../../static/daizhifu.png" mode="widthFix"></image>
						<view>待支付</view>
					</view>
					<view @click="goOrder">
						<image src="../../static/daifuwu.png" mode="widthFix"></image>
						<view>待服务</view>
					</view>
					<view @click="goOrder">
						<image src="../../static/quxiaodingdan.png" mode="widthFix"></image>
						<view>已取消</view>
					</view>
				</view>
			</view>

			<button @click="orderTaker" v-if="userinfoAll2.is_taker&&userinfo">
				<view class="Firstone">
					<view class="Firstpu_w" style="margin-top:5rpx;">
						<image src="../../static/daifuwu.png" mode="" class="Firstpuper"></image>
					</view>
					<view class="wodes">接单员接单</view>
					<view class="rights">
						<image src="../../static/right.png" mode="widthFix"></image>
					</view>
				</view>
			</button>

			<button @click="takingOrders" v-if="userinfoAll2.taker_id==0&&userinfo">
				<view class="Firstone">
					<view class="Firstpu_w" style="margin-top:5rpx;">
						<image src="../../static/daifuwu.png" mode="" class="Firstpuper"></image>
					</view>
					<view class="wodes">接单员入驻</view>
					<view class="rights">
						<image src="../../static/right.png" mode="widthFix"></image>
					</view>
				</view>
			</button>

			<button @click="goJiuzhen">
				<view class="Firstone">
					<view class="Firstpu_w" style="margin-top:5rpx;">
						<image src="../../static/jiuzhenrxinxi.png" mode="" class="Firstpuper"></image>
					</view>
					<view class="wodes">就诊人信息</view>
					<view class="rights">
						<image src="../../static/right.png" mode="widthFix"></image>
					</view>
				</view>
			</button>
			<button open-type="contact">
				<view class="Firstone">
					<view class="Firstpu_w" style="margin-top: 5rpx;">
						<image src="../../static/wodekefu.png" mode="" class="Firstpuper"></image>
					</view>
					<view class="wodes">我的客服</view>
					<view class="rights">
						<image src="../../static/right.png" mode="widthFix"></image>
					</view>
				</view>
			</button>

			<!-- <button @click="goaboutus">
				<view class="Firstone">
					<view class="Firstpu_w" style="margin-top: 5rpx;"><image src="../../static/about_us.png" mode="" class="Firstpuper"></image></view>
					<view class="wodes">关于我们</view>
					<view class="rights"><image src="../../static/right.png" mode="widthFix"></image></view>
				</view>
			</button> -->

			<button @click="yinsixieyi">
				<view class="Firstone">
					<view class="Firstpu_w" style="margin-top: 5rpx;">
						<image src="../../static/yinsixieyi.png" mode="" class="Firstpuper"></image>
					</view>
					<view class="wodes">隐私协议</view>
					<view class="rights">
						<image src="../../static/right.png" mode="widthFix"></image>
					</view>
				</view>
			</button>

			<button @click="yonghufuwuxieyi">
				<view class="Firstone">
					<view class="Firstpu_w" style="margin-top: 5rpx;">
						<image src="../../static/yonghufuwuxieyi.png" mode="" class="Firstpuper"></image>
					</view>
					<view class="wodes">用户服务协议</view>
					<view class="rights">
						<image src="../../static/right.png" mode="widthFix"></image>
					</view>
				</view>
			</button>
			<button @click="fxm">
				<view class="Firstone">
					<view class="Firstpu_w" style="margin-top: 5rpx;">
						<image src="../../static/fxm.png" mode="" class="Firstpuper"></image>
					</view>
					<view class="wodes">分享码</view>
					<view class="rights">
						<image src="../../static/right.png" mode="widthFix"></image>
					</view>
				</view>
			</button>
			<button @click="sz">
				<view class="Firstone">
					<view class="Firstpu_w" style="margin-top: 5rpx;">
						<image src="../../static/sz.png" mode="" class="Firstpuper"></image>
					</view>
					<view class="wodes">设置</view>
					<view class="rights">
						<image src="../../static/right.png" mode="widthFix"></image>
					</view>
				</view>
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userinfo: {},
				bgImage: 'https://20240202xhfpeizhenxiaochengxu.rchz.top/uploads/20240307/f7eda4d2d7e30e2e2150236373f90046.png',
				fximage: 'https://20240202xhfpeizhenxiaochengxu.rchz.top/uploads/20240307/53a341fd4b39970a812d7680f2b137df.png',
				userinfoAll2: '',
				userId: uni.getStorageSync('userinfo')
			};
		},
		onLoad() {
			
			this.userinfo = uni.getStorageSync('userinfo');
			this.userinfoAll2 = uni.getStorageSync('userinfoAll');
			console.log(this.userinfo,this.userinfoAll2,'8888888888888888888')
		},
		onShow() {
			console.log(22222)
			this.getUserinfo()
			this.userinfoAll2 = uni.getStorageSync('userinfoAll');
			console.log(this.userinfoAll2, "/？？？？？？？？？？")
			this.userinfo = uni.getStorageSync('userinfo');
			if (!uni.getStorageSync('user_id')) {
				uni.showToast({
					title: '请先登录',
					icon: 'none'
				});
				return;
			}
		},
		onShareAppMessage(res) {
			return {
				title: '怡尔康医疗服务平台',
				path: '/pages/index/index',
				imageUrl: this.fximage //这个是分享的图片
			};
		},
		methods: {
			getUserinfo() {
				let id = uni.getStorageSync('user_id');
				let self = this;
				this._get('/api/newadd/getuserinfo', {
					id: id
				}, function(res) {
					console.log(res.data, '获取用户信息')
					if (res.code == 1) {
						uni.setStorageSync('userinfoAll', res.data)
					}
					// self.cityID = res.data.id;
					// self.cityname = res.data.name;
					// self.getHospitalList();
				});
			},
			getUserProfile() {
				console.log(123);
				uni.showLoading({
					title: '登录中...'
				});

				let self = this;
				uni.getUserProfile({
					desc: 'weixin',
					success: function(infoRes) {
						console.log(infoRes, 'getUserProfile数据');
						uni.login({
							provider: 'weixin',
							success: function(loginRes) {
								console.log(loginRes, 'login数据');
								self._post(
									'/api/login/index', {
										js_code: loginRes.code,
										avatar: infoRes.userInfo.avatarUrl,
										nickName: infoRes.userInfo.nickName
									},
									function(res) {
										// console.log(res, '1111111111');
										// return
										console.log(res, '数据参数');
										uni.navigateTo({
											url: './ReLogin?userinfo=' + JSON
												.stringify(infoRes.userInfo) +
												'&token=' + res.data.token +
												'&user_id=' + res.data.user_id
										});
										uni.setStorageSync('session_key', res.data
											.session_key);
										// self.session_key = res.data.session_key
										// uni.setStorageSync('token', res.data.token)
										uni.setStorageSync('user_id', res.data.user_id);

										uni.setStorageSync('userinfoAll', res.data)
									},
									function(err) {
										console.log('err', err);
									}
								);
							}
						});
					}
				});
				setTimeout(() => {
					// 数据从后端接口返回后，提示弹框关闭
					uni.hideLoading();
				}, 1500);
			},
			Seeadoctor() {
				this.isLogin();
				uni.navigateTo({
					url: './Administration/patient'
				});
			},
			goOrder() {
				uni.switchTab({
					url: '/pages/Order/Order'
				});
			},
			goJiuzhen() {
				uni.navigateTo({
					url: './Administration/patient'
				});
			},
			orderTaker() {
				uni.navigateTo({
					url: '/pages/My/orderTaker'
				});
			},
			takingOrders() {
				uni.navigateTo({
					url: '/pages/My/takingOrders'
				});
			},
			goaboutus() {
				uni.navigateTo({
					url: './Administration/aboutUs'
				});
			},
			yinsixieyi() {
				uni.navigateTo({
					url: './Administration/yinsixieyi/yinsixieyi'
				});
			},
			sz() {
				uni.navigateTo({
					url: '/pages/My/set/set'
				});
			},
			fxm() {
				uni.navigateTo({
					url: '/pages/My/fxm/fxm'
				});
			},
			yonghufuwuxieyi() {
				uni.navigateTo({
					url: './Administration/yonghufuwuxieyi/yonghufuwuxieyi'
				});
			},
			userAgreement() {
				uni.navigateTo({
					url: './Administration/user_agreement'
				});
			},
			privacyAgreement() {
				uni.navigateTo({
					url: './Administration/privacy_agreement'
				});
			},
			// 去登录
			goLogin() {
				if (uni.getStorageSync('token')) {
					return false;
				} else {
					uni.navigateTo({
						url: './ReLogin'
					});
				}
			}
		}
	};
</script>

<style lang="scss">
	.order-type {
		display: flex;
		justify-content: space-around;
		align-items: center;
		margin-top: 15rpx;
		width: 100%;

		view {
			display: flex;
			flex-direction: column;
			align-items: center;
			color: #999999;
		}

		image {
			width: 55rpx;
			height: 55rpx;
			margin-bottom: 10rpx;
		}
	}

	.myorder {
		padding: 18rpx 0rpx 10rpx 30rpx;
		font-size: 35rpx;
		font-weight: bold;
		color: #333333;
	}

	/* 选项栏样式 */
	.wodes_B {
		margin-left: 30rpx;
		margin-right: -30rpx;
		margin-top: 5rpx;
	}

	.wodess {
		margin-left: 30rpx;
		margin-right: 60rpx;
		margin-top: 5rpx;
	}

	.order {
		width: 670rpx;
		background-color: #fff;
		height: 215rpx;
		border-radius: 20rpx;
		margin: 0 auto;
		position: relative;
		top: -30rpx;
		box-shadow: 2rpx 2rpx 5rpx #ccc;
	}

	.rights {
		// margin-left: 300rpx;
		position: absolute;
		right: 80rpx;
		top: 25rpx;
		color: #424f5e;
		background-color: #fff;
		width: 73rpx;
		height: 251rpx !important;
		/* margin-top: 10rpx; */

		image {
			width: 35rpx;
			height: 35rpx;
		}
	}

	.wodes {
		margin-left: 25rpx;
		margin-top: 16rpx;
		font-size: 37rpx;
	}

	.Firstone {
		display: flex;
		width: 630rpx;
		font-size: 32rpx;
		color: #000;
		background-color: #fff;
		padding-left: 40rpx;
		margin-left: 20rpx;
		border-radius: 14rpx;
	}

	.Firstpuper {
		width: 55rpx;
		height: 55rpx;
		margin-top: 35rpx;
	}

	/* 头像部分样式 */
	.nickname {
		margin-left: 20rpx;
		color: #666;
	}

	.headportrait_A {
		width: 105rpx;
		height: 105rpx;
		border-radius: 20rpx;
		background: linear-gradient(#5f5af7, #d6d5fd);
	}

	.headportrait {
		width: 105rpx;
		height: 105rpx;
		border-radius: 20rpx;
	}

	.Khead {
		position: absolute;
		top: 150rpx;
		left: 40rpx;
	}

	.Kheadportrait {
		display: flex;
		align-items: center;
	}

	/* 顶部标题 */
	.Toptitle {
		text-align: center;
		color: #5f5af7;
		font-size: 35rpx;
		font-weight: 900;
		margin-bottom: 35rpx;
		margin-top: 55rpx;
		margin-left: 10rpx;
	}

	.topone {
		background-color: #fafafa;
		height: 100vh;
	}

	button {
		background-color: #fff;
		background: none;
		text-align: left;
		margin-bottom: 18rpx;
	}

	button::after {
		border: none;
	}

	.Firstpu_w image {
		margin-top: 30rpx;
		width: 55rpx;
		height: 55rpx;
	}
</style>